#include <pthread.h>
#include <iostream>

class LockGuard
{
public:
	LockGuard()
	{
		pthread_mutex_init(&_mtx, nullptr);
		std::cout << "LockGuard()" << std::endl;
	}

	void lock()
	{
		pthread_mutex_lock(&_mtx);
	}

	void unlock()
	{
		pthread_mutex_unlock(&_mtx);
	}

	~LockGuard()
	{
		pthread_mutex_destroy(&_mtx);
		std::cout << "~LockGuard()" << std::endl;
	}
private:
	pthread_mutex_t _mtx;
};

